﻿Option Strict On
Option Explicit On 

Imports IP.Core.IPCommon
Imports IP.Core.IPException
Imports IP.Core.IPDataControl
Imports IP.Core.IPData


Imports IP.Core.IPUserService

''' -----------------------------------------------------------------------------
''' Project	 : IPSystemAdmin
''' Class	 : Core.IPSystemAdmin.f115_quan_ly_user_de
''' 
''' -----------------------------------------------------------------------------
''' <summary>
''' Quản lý user, cập nhật thông tin
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' 	[csung]	3/12/2005	Created
''' </history>
''' -----------------------------------------------------------------------------
Class f115_quan_ly_user_de
    Inherits System.Windows.Forms.Form
    Implements I_DEDataContainer

#Region "PUBLIC"
    Public Sub addnew_user(ByVal i_ds_user As DS_HT_NGUOI_SU_DUNG)
        m_st_start_state = DataEntryFormMode.InsertDataState
        m_ds_user = i_ds_user
        Me.ShowDialog()
    End Sub

    Public Sub view_detail_user(ByVal i_ds_user As DS_HT_NGUOI_SU_DUNG, _
                                ByVal i_us_start_user As US_HT_NGUOI_SU_DUNG)
        m_st_start_state = DataEntryFormMode.ViewDataState
        m_us_start_user = i_us_start_user
        m_ds_user = i_ds_user
        Me.ShowDialog()
    End Sub
#End Region





#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call
        format_controls()
    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents m_panel As System.Windows.Forms.Panel
    Friend WithEvents m_lbl_ghi_chu As System.Windows.Forms.Label
    Friend WithEvents m_lbl_name As System.Windows.Forms.Label
    Friend WithEvents m_txt_username As System.Windows.Forms.TextBox
    Friend WithEvents m_txt_password As System.Windows.Forms.TextBox
    Friend WithEvents m_txt_password_verify As System.Windows.Forms.TextBox
    Friend WithEvents m_cbo_thuoc_nhom As System.Windows.Forms.ComboBox
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents Label4 As System.Windows.Forms.Label
    Friend WithEvents m_stMess As System.Windows.Forms.StatusBarPanel
    Friend WithEvents m_stb_fms_style As System.Windows.Forms.StatusBar
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents m_cbo_user_status As System.Windows.Forms.ComboBox
    Friend WithEvents ImageList As System.Windows.Forms.ImageList
    Friend WithEvents m_cmd_previous As SIS.Controls.Button.SiSButton
    Friend WithEvents m_cmd_next As SIS.Controls.Button.SiSButton
    Friend WithEvents m_cmd_insert As SIS.Controls.Button.SiSButton
    Friend WithEvents m_cmd_save As SIS.Controls.Button.SiSButton
    Friend WithEvents m_cmd_update As SIS.Controls.Button.SiSButton
    Friend WithEvents m_cmd_cancel As SIS.Controls.Button.SiSButton
    Friend WithEvents m_cmd_thoat As SIS.Controls.Button.SiSButton
    Friend WithEvents m_pnl_main_data As System.Windows.Forms.Panel
    Friend WithEvents m_txt_ten_that_cua_user As System.Windows.Forms.TextBox
    Friend WithEvents m_stStatus As System.Windows.Forms.StatusBarPanel
    Friend WithEvents m_chk_change_first As System.Windows.Forms.CheckBox
    Friend WithEvents m_chk_cannot_change As System.Windows.Forms.CheckBox
    Friend WithEvents m_chk_never_exp As System.Windows.Forms.CheckBox
    Friend WithEvents m_chk_lock_pass As System.Windows.Forms.CheckBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(f115_quan_ly_user_de))
        Me.m_panel = New System.Windows.Forms.Panel
        Me.m_cmd_previous = New SIS.Controls.Button.SiSButton
        Me.ImageList = New System.Windows.Forms.ImageList(Me.components)
        Me.m_cmd_next = New SIS.Controls.Button.SiSButton
        Me.m_cmd_insert = New SIS.Controls.Button.SiSButton
        Me.m_cmd_update = New SIS.Controls.Button.SiSButton
        Me.m_cmd_save = New SIS.Controls.Button.SiSButton
        Me.m_cmd_cancel = New SIS.Controls.Button.SiSButton
        Me.m_cmd_thoat = New SIS.Controls.Button.SiSButton
        Me.m_pnl_main_data = New System.Windows.Forms.Panel
        Me.m_chk_lock_pass = New System.Windows.Forms.CheckBox
        Me.m_chk_never_exp = New System.Windows.Forms.CheckBox
        Me.m_chk_cannot_change = New System.Windows.Forms.CheckBox
        Me.m_chk_change_first = New System.Windows.Forms.CheckBox
        Me.m_cbo_user_status = New System.Windows.Forms.ComboBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.Label4 = New System.Windows.Forms.Label
        Me.Label3 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.m_cbo_thuoc_nhom = New System.Windows.Forms.ComboBox
        Me.m_txt_password_verify = New System.Windows.Forms.TextBox
        Me.m_txt_password = New System.Windows.Forms.TextBox
        Me.m_lbl_ghi_chu = New System.Windows.Forms.Label
        Me.m_lbl_name = New System.Windows.Forms.Label
        Me.m_txt_ten_that_cua_user = New System.Windows.Forms.TextBox
        Me.m_txt_username = New System.Windows.Forms.TextBox
        Me.m_stMess = New System.Windows.Forms.StatusBarPanel
        Me.m_stb_fms_style = New System.Windows.Forms.StatusBar
        Me.m_stStatus = New System.Windows.Forms.StatusBarPanel
        Me.m_panel.SuspendLayout()
        Me.m_pnl_main_data.SuspendLayout()
        CType(Me.m_stMess, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.m_stStatus, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'm_panel
        '
        Me.m_panel.Controls.Add(Me.m_cmd_previous)
        Me.m_panel.Controls.Add(Me.m_cmd_next)
        Me.m_panel.Controls.Add(Me.m_cmd_insert)
        Me.m_panel.Controls.Add(Me.m_cmd_update)
        Me.m_panel.Controls.Add(Me.m_cmd_save)
        Me.m_panel.Controls.Add(Me.m_cmd_cancel)
        Me.m_panel.Controls.Add(Me.m_cmd_thoat)
        Me.m_panel.Dock = System.Windows.Forms.DockStyle.Bottom
        Me.m_panel.DockPadding.All = 4
        Me.m_panel.Location = New System.Drawing.Point(0, 270)
        Me.m_panel.Name = "m_panel"
        Me.m_panel.Size = New System.Drawing.Size(556, 44)
        Me.m_panel.TabIndex = 1
        '
        'm_cmd_previous
        '
        Me.m_cmd_previous.AdjustImageLocation = New System.Drawing.Point(0, 0)
        Me.m_cmd_previous.BtnShape = SIS.Controls.Button.emunType.BtnShape.Rectangle
        Me.m_cmd_previous.BtnStyle = SIS.Controls.Button.emunType.XPStyle.Default
        Me.m_cmd_previous.Dock = System.Windows.Forms.DockStyle.Right
        Me.m_cmd_previous.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.m_cmd_previous.ImageList = Me.ImageList
        Me.m_cmd_previous.Location = New System.Drawing.Point(102, 4)
        Me.m_cmd_previous.Name = "m_cmd_previous"
        Me.m_cmd_previous.Size = New System.Drawing.Size(42, 36)
        Me.m_cmd_previous.TabIndex = 1
        Me.m_cmd_previous.Text = "<&<"
        '
        'ImageList
        '
        Me.ImageList.ImageSize = New System.Drawing.Size(16, 16)
        Me.ImageList.ImageStream = CType(resources.GetObject("ImageList.ImageStream"), System.Windows.Forms.ImageListStreamer)
        Me.ImageList.TransparentColor = System.Drawing.Color.Transparent
        '
        'm_cmd_next
        '
        Me.m_cmd_next.AdjustImageLocation = New System.Drawing.Point(0, 0)
        Me.m_cmd_next.BtnShape = SIS.Controls.Button.emunType.BtnShape.Rectangle
        Me.m_cmd_next.BtnStyle = SIS.Controls.Button.emunType.XPStyle.Default
        Me.m_cmd_next.Dock = System.Windows.Forms.DockStyle.Right
        Me.m_cmd_next.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.m_cmd_next.ImageList = Me.ImageList
        Me.m_cmd_next.Location = New System.Drawing.Point(144, 4)
        Me.m_cmd_next.Name = "m_cmd_next"
        Me.m_cmd_next.Size = New System.Drawing.Size(42, 36)
        Me.m_cmd_next.TabIndex = 2
        Me.m_cmd_next.Text = "&>>"
        '
        'm_cmd_insert
        '
        Me.m_cmd_insert.AdjustImageLocation = New System.Drawing.Point(0, 0)
        Me.m_cmd_insert.BtnShape = SIS.Controls.Button.emunType.BtnShape.Rectangle
        Me.m_cmd_insert.BtnStyle = SIS.Controls.Button.emunType.XPStyle.Default
        Me.m_cmd_insert.Dock = System.Windows.Forms.DockStyle.Right
        Me.m_cmd_insert.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.m_cmd_insert.ImageIndex = 9
        Me.m_cmd_insert.ImageList = Me.ImageList
        Me.m_cmd_insert.Location = New System.Drawing.Point(186, 4)
        Me.m_cmd_insert.Name = "m_cmd_insert"
        Me.m_cmd_insert.Size = New System.Drawing.Size(80, 36)
        Me.m_cmd_insert.TabIndex = 3
        Me.m_cmd_insert.Text = "Thê&m mới"
        '
        'm_cmd_update
        '
        Me.m_cmd_update.AdjustImageLocation = New System.Drawing.Point(0, 0)
        Me.m_cmd_update.BtnShape = SIS.Controls.Button.emunType.BtnShape.Rectangle
        Me.m_cmd_update.BtnStyle = SIS.Controls.Button.emunType.XPStyle.Default
        Me.m_cmd_update.Dock = System.Windows.Forms.DockStyle.Right
        Me.m_cmd_update.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.m_cmd_update.ImageIndex = 3
        Me.m_cmd_update.ImageList = Me.ImageList
        Me.m_cmd_update.Location = New System.Drawing.Point(266, 4)
        Me.m_cmd_update.Name = "m_cmd_update"
        Me.m_cmd_update.Size = New System.Drawing.Size(66, 36)
        Me.m_cmd_update.TabIndex = 4
        Me.m_cmd_update.Text = "&Sửa"
        '
        'm_cmd_save
        '
        Me.m_cmd_save.AdjustImageLocation = New System.Drawing.Point(0, 0)
        Me.m_cmd_save.BtnShape = SIS.Controls.Button.emunType.BtnShape.Rectangle
        Me.m_cmd_save.BtnStyle = SIS.Controls.Button.emunType.XPStyle.Default
        Me.m_cmd_save.Dock = System.Windows.Forms.DockStyle.Right
        Me.m_cmd_save.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.m_cmd_save.ImageIndex = 10
        Me.m_cmd_save.ImageList = Me.ImageList
        Me.m_cmd_save.Location = New System.Drawing.Point(332, 4)
        Me.m_cmd_save.Name = "m_cmd_save"
        Me.m_cmd_save.Size = New System.Drawing.Size(66, 36)
        Me.m_cmd_save.TabIndex = 6
        Me.m_cmd_save.Text = "&Lưu"
        '
        'm_cmd_cancel
        '
        Me.m_cmd_cancel.AdjustImageLocation = New System.Drawing.Point(0, 0)
        Me.m_cmd_cancel.BtnShape = SIS.Controls.Button.emunType.BtnShape.Rectangle
        Me.m_cmd_cancel.BtnStyle = SIS.Controls.Button.emunType.XPStyle.Default
        Me.m_cmd_cancel.Dock = System.Windows.Forms.DockStyle.Right
        Me.m_cmd_cancel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.m_cmd_cancel.ImageIndex = 8
        Me.m_cmd_cancel.ImageList = Me.ImageList
        Me.m_cmd_cancel.Location = New System.Drawing.Point(398, 4)
        Me.m_cmd_cancel.Name = "m_cmd_cancel"
        Me.m_cmd_cancel.Size = New System.Drawing.Size(80, 36)
        Me.m_cmd_cancel.TabIndex = 7
        Me.m_cmd_cancel.Text = "&Hủy bỏ"
        '
        'm_cmd_thoat
        '
        Me.m_cmd_thoat.AdjustImageLocation = New System.Drawing.Point(0, 0)
        Me.m_cmd_thoat.BtnShape = SIS.Controls.Button.emunType.BtnShape.Rectangle
        Me.m_cmd_thoat.BtnStyle = SIS.Controls.Button.emunType.XPStyle.Default
        Me.m_cmd_thoat.Dock = System.Windows.Forms.DockStyle.Right
        Me.m_cmd_thoat.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
        Me.m_cmd_thoat.ImageIndex = 11
        Me.m_cmd_thoat.ImageList = Me.ImageList
        Me.m_cmd_thoat.Location = New System.Drawing.Point(478, 4)
        Me.m_cmd_thoat.Name = "m_cmd_thoat"
        Me.m_cmd_thoat.Size = New System.Drawing.Size(74, 36)
        Me.m_cmd_thoat.TabIndex = 8
        Me.m_cmd_thoat.Text = "&Thoát"
        '
        'm_pnl_main_data
        '
        Me.m_pnl_main_data.Controls.Add(Me.m_chk_lock_pass)
        Me.m_pnl_main_data.Controls.Add(Me.m_chk_never_exp)
        Me.m_pnl_main_data.Controls.Add(Me.m_chk_cannot_change)
        Me.m_pnl_main_data.Controls.Add(Me.m_chk_change_first)
        Me.m_pnl_main_data.Controls.Add(Me.m_cbo_user_status)
        Me.m_pnl_main_data.Controls.Add(Me.Label1)
        Me.m_pnl_main_data.Controls.Add(Me.Label4)
        Me.m_pnl_main_data.Controls.Add(Me.Label3)
        Me.m_pnl_main_data.Controls.Add(Me.Label2)
        Me.m_pnl_main_data.Controls.Add(Me.m_cbo_thuoc_nhom)
        Me.m_pnl_main_data.Controls.Add(Me.m_txt_password_verify)
        Me.m_pnl_main_data.Controls.Add(Me.m_txt_password)
        Me.m_pnl_main_data.Controls.Add(Me.m_lbl_ghi_chu)
        Me.m_pnl_main_data.Controls.Add(Me.m_lbl_name)
        Me.m_pnl_main_data.Controls.Add(Me.m_txt_ten_that_cua_user)
        Me.m_pnl_main_data.Controls.Add(Me.m_txt_username)
        Me.m_pnl_main_data.Dock = System.Windows.Forms.DockStyle.Fill
        Me.m_pnl_main_data.Location = New System.Drawing.Point(0, 0)
        Me.m_pnl_main_data.Name = "m_pnl_main_data"
        Me.m_pnl_main_data.Size = New System.Drawing.Size(556, 270)
        Me.m_pnl_main_data.TabIndex = 0
        '
        'm_chk_lock_pass
        '
        Me.m_chk_lock_pass.Location = New System.Drawing.Point(318, 182)
        Me.m_chk_lock_pass.Name = "m_chk_lock_pass"
        Me.m_chk_lock_pass.Size = New System.Drawing.Size(196, 24)
        Me.m_chk_lock_pass.TabIndex = 15
        Me.m_chk_lock_pass.Text = "Account is disable"
        '
        'm_chk_never_exp
        '
        Me.m_chk_never_exp.Location = New System.Drawing.Point(318, 152)
        Me.m_chk_never_exp.Name = "m_chk_never_exp"
        Me.m_chk_never_exp.Size = New System.Drawing.Size(196, 24)
        Me.m_chk_never_exp.TabIndex = 14
        Me.m_chk_never_exp.Text = "Password never expire"
        '
        'm_chk_cannot_change
        '
        Me.m_chk_cannot_change.Location = New System.Drawing.Point(318, 118)
        Me.m_chk_cannot_change.Name = "m_chk_cannot_change"
        Me.m_chk_cannot_change.Size = New System.Drawing.Size(210, 24)
        Me.m_chk_cannot_change.TabIndex = 13
        Me.m_chk_cannot_change.Text = "User cannot change password"
        '
        'm_chk_change_first
        '
        Me.m_chk_change_first.Location = New System.Drawing.Point(318, 86)
        Me.m_chk_change_first.Name = "m_chk_change_first"
        Me.m_chk_change_first.Size = New System.Drawing.Size(236, 24)
        Me.m_chk_change_first.TabIndex = 12
        Me.m_chk_change_first.Text = "User must change password at next logon"
        '
        'm_cbo_user_status
        '
        Me.m_cbo_user_status.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.m_cbo_user_status.Location = New System.Drawing.Point(372, 6)
        Me.m_cbo_user_status.Name = "m_cbo_user_status"
        Me.m_cbo_user_status.Size = New System.Drawing.Size(122, 21)
        Me.m_cbo_user_status.TabIndex = 3
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(316, 6)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(56, 20)
        Me.Label1.TabIndex = 2
        Me.Label1.Text = "Status"
        Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label4
        '
        Me.Label4.Location = New System.Drawing.Point(12, 40)
        Me.Label4.Name = "Label4"
        Me.Label4.Size = New System.Drawing.Size(84, 20)
        Me.Label4.TabIndex = 4
        Me.Label4.Text = "In group"
        Me.Label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label3
        '
        Me.Label3.Location = New System.Drawing.Point(12, 120)
        Me.Label3.Name = "Label3"
        Me.Label3.Size = New System.Drawing.Size(84, 20)
        Me.Label3.TabIndex = 8
        Me.Label3.Text = "Password"
        Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(4, 154)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(92, 20)
        Me.Label2.TabIndex = 10
        Me.Label2.Text = "Retype password"
        Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'm_cbo_thuoc_nhom
        '
        Me.m_cbo_thuoc_nhom.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.m_cbo_thuoc_nhom.Location = New System.Drawing.Point(102, 40)
        Me.m_cbo_thuoc_nhom.Name = "m_cbo_thuoc_nhom"
        Me.m_cbo_thuoc_nhom.Size = New System.Drawing.Size(390, 21)
        Me.m_cbo_thuoc_nhom.TabIndex = 5
        '
        'm_txt_password_verify
        '
        Me.m_txt_password_verify.Location = New System.Drawing.Point(102, 154)
        Me.m_txt_password_verify.Name = "m_txt_password_verify"
        Me.m_txt_password_verify.PasswordChar = Microsoft.VisualBasic.ChrW(42)
        Me.m_txt_password_verify.Size = New System.Drawing.Size(204, 20)
        Me.m_txt_password_verify.TabIndex = 11
        Me.m_txt_password_verify.Text = "m_txt_password_verify"
        '
        'm_txt_password
        '
        Me.m_txt_password.Location = New System.Drawing.Point(102, 120)
        Me.m_txt_password.Name = "m_txt_password"
        Me.m_txt_password.PasswordChar = Microsoft.VisualBasic.ChrW(42)
        Me.m_txt_password.Size = New System.Drawing.Size(204, 20)
        Me.m_txt_password.TabIndex = 9
        Me.m_txt_password.Text = "m_txt_password"
        '
        'm_lbl_ghi_chu
        '
        Me.m_lbl_ghi_chu.Location = New System.Drawing.Point(12, 88)
        Me.m_lbl_ghi_chu.Name = "m_lbl_ghi_chu"
        Me.m_lbl_ghi_chu.Size = New System.Drawing.Size(84, 20)
        Me.m_lbl_ghi_chu.TabIndex = 6
        Me.m_lbl_ghi_chu.Text = "Full name"
        Me.m_lbl_ghi_chu.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'm_lbl_name
        '
        Me.m_lbl_name.Location = New System.Drawing.Point(12, 6)
        Me.m_lbl_name.Name = "m_lbl_name"
        Me.m_lbl_name.Size = New System.Drawing.Size(84, 20)
        Me.m_lbl_name.TabIndex = 0
        Me.m_lbl_name.Text = "Login name"
        Me.m_lbl_name.TextAlign = System.Drawing.ContentAlignment.MiddleRight
        '
        'm_txt_ten_that_cua_user
        '
        Me.m_txt_ten_that_cua_user.Location = New System.Drawing.Point(102, 88)
        Me.m_txt_ten_that_cua_user.Name = "m_txt_ten_that_cua_user"
        Me.m_txt_ten_that_cua_user.Size = New System.Drawing.Size(206, 20)
        Me.m_txt_ten_that_cua_user.TabIndex = 7
        Me.m_txt_ten_that_cua_user.Text = "m_txt_ten_that_cua_user"
        '
        'm_txt_username
        '
        Me.m_txt_username.Location = New System.Drawing.Point(102, 6)
        Me.m_txt_username.Name = "m_txt_username"
        Me.m_txt_username.Size = New System.Drawing.Size(204, 20)
        Me.m_txt_username.TabIndex = 1
        Me.m_txt_username.Text = "m_txt_username"
        '
        'm_stMess
        '
        Me.m_stMess.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring
        Me.m_stMess.Icon = CType(resources.GetObject("m_stMess.Icon"), System.Drawing.Icon)
        Me.m_stMess.Width = 446
        '
        'm_stb_fms_style
        '
        Me.m_stb_fms_style.ImeMode = System.Windows.Forms.ImeMode.NoControl
        Me.m_stb_fms_style.Location = New System.Drawing.Point(0, 314)
        Me.m_stb_fms_style.Name = "m_stb_fms_style"
        Me.m_stb_fms_style.Panels.AddRange(New System.Windows.Forms.StatusBarPanel() {Me.m_stMess, Me.m_stStatus})
        Me.m_stb_fms_style.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.m_stb_fms_style.ShowPanels = True
        Me.m_stb_fms_style.Size = New System.Drawing.Size(556, 22)
        Me.m_stb_fms_style.TabIndex = 2
        Me.m_stb_fms_style.Text = "statusBar"
        '
        'm_stStatus
        '
        Me.m_stStatus.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents
        Me.m_stStatus.Text = "Status  of  Form"
        Me.m_stStatus.Width = 94
        '
        'f115_quan_ly_user_de
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(556, 336)
        Me.Controls.Add(Me.m_pnl_main_data)
        Me.Controls.Add(Me.m_panel)
        Me.Controls.Add(Me.m_stb_fms_style)
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.Name = "f115_quan_ly_user_de"
        Me.Text = "M115 - User information"
        Me.m_panel.ResumeLayout(False)
        Me.m_pnl_main_data.ResumeLayout(False)
        CType(Me.m_stMess, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.m_stStatus, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

#Region "MEMBERS"
    Private m_st_start_state As IP.Core.IPCommon.DataEntryFormMode
    Private m_ctl_form_and_datasource As CDataAndFormControl
    Private m_ds_user As DS_HT_NGUOI_SU_DUNG
    Private m_us_start_user As US_HT_NGUOI_SU_DUNG
    Private m_us_for_update As US_HT_NGUOI_SU_DUNG
#End Region

#Region "PRIVATE"

    Private Sub set_controls_start_state()
        Me.load_cbo_user_status()
        Me.load_data_2_cbo_nhom()


        Dim v_form_control As New CDEFormStateControl(m_stb_fms_style)
        v_form_control.add_de_button(IPDEButtonEnum.Save, m_cmd_save)
        v_form_control.add_de_button(IPDEButtonEnum.MovePrevious, m_cmd_previous)
        v_form_control.add_de_button(IPDEButtonEnum.MoveNext, m_cmd_next)
        v_form_control.add_de_button(IPDEButtonEnum.Update, m_cmd_update)
        v_form_control.add_de_button(IPDEButtonEnum.Insert, m_cmd_insert)
        v_form_control.add_de_button(IPDEButtonEnum.Cancel, m_cmd_cancel)
        v_form_control.addTextBox(m_txt_password)
        v_form_control.addTextBox(m_txt_password_verify)
        v_form_control.addTextBox(m_txt_ten_that_cua_user)
        v_form_control.addTextBox(m_txt_username)
        v_form_control.addComboBox(m_cbo_thuoc_nhom)
        v_form_control.addComboBox(m_cbo_user_status)

        Dim v_datasource_ctl As New CFormDEDataSourceControl(m_ds_user.HT_NGUOI_SU_DUNG)
        m_ctl_form_and_datasource = New CDataAndFormControl(v_datasource_ctl, v_form_control, Me)
    End Sub

    Private Sub set_form_initial()
        set_controls_start_state()
        Select Case m_st_start_state
            Case DataEntryFormMode.InsertDataState
                m_ctl_form_and_datasource.start_in_insert_mode()
            Case DataEntryFormMode.ViewDataState
                m_ctl_form_and_datasource.start_in_view_mode(m_us_start_user.dcID)
        End Select

    End Sub


    Public Sub format_controls()
        'CControlFormat.setFormStyle(Me, New CApplicationContext, IPFormStyle.DialogForm)
        CControlFormat.setFormStyle(Me, IPFormStyle.DialogForm)
        CControlFormat.set_all_label_style_as_promt(Me)

    End Sub


    Public Sub us_object_2_form(ByVal i_us As US_HT_NGUOI_SU_DUNG)
        If i_us.IsMAT_KHAUNull Then
            m_txt_password.Text = ""
        Else
            Me.m_txt_password.Text = i_us.strMAT_KHAU
        End If
        m_txt_password_verify.Text = m_txt_password.Text
        Me.m_txt_username.Text = i_us.strTEN_TRUY_CAP
        Me.m_txt_ten_that_cua_user.Text = i_us.strTEN_THAT
        Me.m_cbo_thuoc_nhom.SelectedValue = i_us.dcID_NHOM_NGUOI_SU_DUNG
        Me.m_cbo_user_status.SelectedValue = i_us.strTRANG_THAI_NGUOI_SU_DUNG
        Me.m_chk_change_first.Checked = CIPConvert.ToBoolean(i_us.strCHANGE_PASS_FIRST)
        Me.m_chk_cannot_change.Checked = CIPConvert.ToBoolean(i_us.strCANNOT_CHANGE_PASS)
        Me.m_chk_lock_pass.Checked = CIPConvert.ToBoolean(i_us.strLOCK_PASS)
        Me.m_chk_never_exp.Checked = CIPConvert.ToBoolean(i_us.strPASS_NEVER_EXP)
    End Sub

    Public Sub form_2_us_object(ByVal i_us As US_HT_NGUOI_SU_DUNG)
        If Trim(m_txt_username.Text) = "" Then
            i_us.SetTEN_TRUY_CAPNull()
        Else
            i_us.strTEN_TRUY_CAP = (m_txt_username.Text.ToUpper)
        End If

        If Trim(m_txt_password.Text) = "" Then
            i_us.SetMAT_KHAUNull()
        Else
            i_us.strMAT_KHAU = m_txt_password.Text
        End If

        If Trim(m_txt_ten_that_cua_user.Text) = "" Then
            i_us.SetTEN_THATNull()
        Else
            i_us.strTEN_THAT = m_txt_ten_that_cua_user.Text
        End If

        If Trim(m_cbo_thuoc_nhom.Text) = "" Then
            i_us.SetID_NHOM_NGUOI_SU_DUNGNull()
        Else
            i_us.dcID_NHOM_NGUOI_SU_DUNG = CIPConvert.ToDecimal(m_cbo_thuoc_nhom.SelectedValue)
        End If

        If Trim(m_cbo_user_status.Text) = "" Then
            i_us.SetTRANG_THAI_NGUOI_SU_DUNGNull()
        Else
            i_us.strTRANG_THAI_NGUOI_SU_DUNG = CIPConvert.ToStr(m_cbo_user_status.SelectedValue)
        End If
        i_us.strCHANGE_PASS_FIRST = CIPConvert.ToYNString(Me.m_chk_change_first.Checked)
        i_us.strCANNOT_CHANGE_PASS = CIPConvert.ToYNString(Me.m_chk_cannot_change.Checked)
        i_us.strLOCK_PASS = CIPConvert.ToYNString(Me.m_chk_lock_pass.Checked)
        i_us.strPASS_NEVER_EXP = CIPConvert.ToYNString(Me.m_chk_never_exp.Checked)

    End Sub

    Private Sub load_data_2_cbo_nhom()
        Dim v_us_nhom As New US_HT_NHOM_NGUOI_SU_DUNG
        Dim v_ds_nhom As New DS_HT_NHOM_NGUOI_SU_DUNG
        Try
            v_us_nhom.open_connection()
            v_us_nhom.FillDataset(v_ds_nhom)
            m_cbo_thuoc_nhom.DataSource = v_ds_nhom.HT_NHOM_NGUOI_SU_DUNG
            m_cbo_thuoc_nhom.ValueMember = IP.Core.IPData.IPDBName.HT_NHOM_NGUOI_SU_DUNG.ID
            m_cbo_thuoc_nhom.DisplayMember = IP.Core.IPData.IPDBName.HT_NHOM_NGUOI_SU_DUNG.GHI_CHU
            v_us_nhom.commit_close_connection()
        Catch ex As Exception
            If v_us_nhom.is_having_connection Then
                v_us_nhom.rollback_close_connection()
            End If
            IPException.CExpUtils.DefaultDBExpHandler(ex)
        End Try
    End Sub

    Private Sub load_cbo_user_status()
        Dim v_ip_simple_combo As New IPSimpleStringComboBoxManager(m_cbo_user_status)
        v_ip_simple_combo.addItem("NORMAL", "Bình thường")
        v_ip_simple_combo.addItem("ACCESS_DENIED", "Tạm bị cấm")
        v_ip_simple_combo.addItem("NOT_IN_USE", "Không sử dụng nữa")
    End Sub

#End Region

#Region "IMPLEMENT DEDataContainer"


    Sub datarow_2_form(ByVal i_datarow As DataRow) Implements I_DEDataContainer.datarow_2_form
        Dim v_us As New US_HT_NGUOI_SU_DUNG
        v_us.DataRow2Me(i_datarow)
        Me.us_object_2_form(v_us)
    End Sub

    Sub clear_data_in_form() Implements I_DEDataContainer.clear_data_in_form

        m_txt_password.Text = ""
        m_txt_password_verify.Text = ""
        Me.m_txt_username.Text = ""
        Me.m_txt_ten_that_cua_user.Text = ""
        Me.m_cbo_thuoc_nhom.SelectedIndex = 0
        Me.m_cbo_user_status.SelectedValue = US_HT_NGUOI_SU_DUNG.get_default_user_status
    End Sub

    Sub submit_insert_to_db(ByRef o_us_object As US_Object, ByRef o_succeeded As Boolean) Implements I_DEDataContainer.submit_insert_to_db
        Dim v_us_user As New US_HT_NGUOI_SU_DUNG
        Me.form_2_us_object(v_us_user)
        v_us_user.strCREATED_BY = CApplicationContext.get_curent_user
        v_us_user.strUPDATED_BY = CApplicationContext.get_curent_user
        v_us_user.datCREATED_DATE = CApplicationContext.get_current_business_date
        v_us_user.datUPDATED_DATE = CApplicationContext.get_current_business_date
        Try
            v_us_user.open_connection()
            v_us_user.Insert()
            v_us_user.commit_close_connection()
            o_us_object = v_us_user
            o_succeeded = True
        Catch v_ex As Exception
            If v_us_user.is_having_connection Then
                v_us_user.rollback_close_connection()
            End If
            CExpUtils.DefaultDBExpHandler(v_ex)
            o_succeeded = False
        End Try
    End Sub

    Sub submit_update_to_db(ByVal i_current_datarow As DataRow, ByRef o_us_object As US_Object, ByRef o_succeeded As Boolean) _
                        Implements I_DEDataContainer.submit_update_to_db
        Debug.Assert(Not (m_us_for_update Is Nothing), "m_us_for_update khong the nothing duoc")
        Debug.Assert(m_us_for_update.is_having_connection, "m_us_for_update phai co connection")
        'NEW DATA IN FORM TO US OBJECT
        Me.form_2_us_object(m_us_for_update)
        Dim v_us_user As US_HT_NGUOI_SU_DUNG = m_us_for_update

        v_us_user.strUPDATED_BY = CApplicationContext.get_curent_user
        v_us_user.datUPDATED_DATE = CApplicationContext.get_current_business_date
        Try
            v_us_user.Update()
            v_us_user.commit_close_connection()
            o_us_object = v_us_user
            o_succeeded = True
        Catch v_ex As Exception
            If v_us_user.is_having_connection Then
                v_us_user.rollback_close_connection()
            End If
            CExpUtils.DefaultDBExpHandler(v_ex)
            o_succeeded = False
        End Try
    End Sub

    Sub submit_delete_current(ByVal i_current_datarow As DataRow, ByRef o_succeeded As Boolean) _
                        Implements I_DEDataContainer.submit_delete_current
        Dim v_us_user As New US_HT_NGUOI_SU_DUNG
        v_us_user.DataRow2Me(i_current_datarow)
        Try
            v_us_user.open_connection()
            v_us_user.DeleteByID(v_us_user.dcID)
            v_us_user.commit_close_connection()
            o_succeeded = True
        Catch ex As Exception
            If v_us_user.is_having_connection Then
                v_us_user.rollback_close_connection()
            End If
            o_succeeded = False
        End Try
    End Sub

    Sub start_insert_new(ByRef o_is_insertable As Boolean) Implements I_DEDataContainer.start_insert_new
        o_is_insertable = True
    End Sub

    Sub start_update(ByVal i_current_datarow As DataRow, ByRef o_is_updatable As Boolean) _
                        Implements I_DEDataContainer.start_update
        m_us_for_update = New US_HT_NGUOI_SU_DUNG
        m_us_for_update.DataRow2Me(i_current_datarow)
        Try
            m_us_for_update.open_connection()
            m_us_for_update.PrepareUpdate()
            o_is_updatable = True
        Catch v_e As Exception
            If m_us_for_update.is_having_connection Then
                m_us_for_update.rollback_close_connection()
            End If
            IP.Core.IPException.CExpUtils.DefaultDBExpHandler(v_e)
            o_is_updatable = False
        End Try
    End Sub

    Sub start_delete(ByVal i_current_datarow As DataRow, ByRef o_is_deletable As Boolean) Implements I_DEDataContainer.start_delete
        o_is_deletable = True
    End Sub

    Sub cancel_editing() Implements I_DEDataContainer.cancel_editing
        If m_ctl_form_and_datasource.get_current_form_state = IPFormDEState.DE_UpdateState Then
            If m_us_for_update.is_having_connection Then
                m_us_for_update.rollback_close_connection()
            End If
        End If
    End Sub
#End Region

    '''
    ''' Add event handlers
    '''
    ''' 
    ''' 



    Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
        Try
            set_form_initial()
        Catch ex As Exception
            CSystemLog_301.ExceptionHandle(ex)
        End Try
    End Sub

    Private Sub m_cmd_thoat_Click(ByVal sender As System.Object, _
                                 ByVal e As System.EventArgs) Handles m_cmd_thoat.Click
        Try
            Me.Close()
        Catch ex As Exception
            CSystemLog_301.ExceptionHandle(ex)
        End Try

    End Sub





End Class
